<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>购物车</title>
<script type="text/javascript">
	function changePage(method) {
		var pageNo = document.forms[0].pageNo.value;
		var total = document.forms[0].total.value;
		if (method == "next") {
			if (parseInt(pageNo) >= parseInt(total)) {
				alert("当前已经是最后一页！");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) + 1;
			}
		}
		if (method == "previous") {
			if (parseInt(pageNo) <= 1) {
				alert("当前已经是第一页");
				return false;
			} else {
				document.forms[0].pageNo.value = parseInt(pageNo) - 1;
			}
		}
		if (method == "first") {
			document.forms[0].pageNo.value = 1;
		}
		if (method == "end") {
			document.forms[0].pageNo.value = total;
		}

		document.forms[0].submit();
	}
</script>
</head>
<body>
	<div style="float:right;">
		欢迎您:<a href="<c:url value='/UserInfoAction?oper=personaledit&id=${userInfologin.id}'/>">${userInfologin.userName }</a>
	</div>
<div style="width:800px;height:50px;">
	
	<ul class="nav nav-pills">
   <li><a href="<c:url value='/ClothingAction?oper=defaultlist'/>">首页</a></li>
   <li class="active"><a href="<c:url value='/BuycarAction?oper=list'/>">我的购物车</a></li>
   <li><a href="<c:url value='UserInfoAction?oper=myOrder'/>">我的订单</a></li>
   <li><a href="<c:url value='/UserInfoAction?oper=loginout'/>">退出登录</a></li>
</ul>
</div>
<div class="clearfix"></div>
	<span>${msg }</span>

			<form action="<c:url value='/BuycarAction?oper=list'/>" method="post">
					<input type="hidden" name="pageNo" value="${pageNo}"> 
					<input type="hidden" name="total" value="${total}"> 
			</form>
			
		总价为：<span>${totalprice }￥</span>
				
	 <table class="table table-hover">
   <thead>
      <tr>
         <th>名称</th>
         <th>价格</th>
         <th>售价</th>
         <th>尺寸</th>
         <th>颜色</th>
         <th>图片</th>
         <th>操作</th>
      </tr>
   </thead>
   <tbody>
    <c:forEach items="${clothinglist }" var="clothing">
			<tr>
				<td>${clothing.name }</td>
				<td>${clothing.price}￥</td>
				<td>${clothing.saleprice}￥</td>
				<td>${clothing.size}</td>
				<td>${clothing.color }</td>
				<td>${clothing.picture}</td>

				<td style="margin:0 auto;">
				<a href="<c:url value='/BuycarAction?oper=delete&id=${clothing.id}'/>" >
				<b class="glyphicon glyphicon-trash"></b>
				</a>
				</td>
			<td>
			<form action="<c:url value='/BuycarAction?oper=update&id=${clothing.id }'/>" method="post">
				
				<div class="input-group">
		         <input type="text"  style="float:left;width:40px;height:20px;" size="1" name="amount" value="${clothing.amount }">
		         <button type="submit" style="float:left;"><b class="glyphicon glyphicon-pencil"></b></button>
		      </div>
			</form>
			</td>
			</tr>
		</c:forEach>
   </tbody>
</table>
<div class="text-center">
		<c:if test ="${!empty clothinglist }">
		<a href="<c:url value='/BuycarAction?oper=deleteall'/>">清空购物车</a>
		<a href ="<c:url value='/BuycarAction?oper=sendorder'/>">发送订单</a>
		</c:if>
</div>

<div class="text-center">
			查询到：${count}条记录
			<a href="#" onclick="changePage('first')">首页</a> 
			<a href="#" onclick="changePage('previous')">上一页</a> 
			<a href="#" onclick="changePage('next')">下一页</a>
			 第${ pageNo}页/共${total}页
			<a href="#" onclick="changePage('end')">尾页</a>
</div>
	
</body>
</html>